package com.cwd.arm.infrastructure.dao.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.cwd.arm.common.util.DateUtil;
import com.cwd.arm.infrastructure.dao.ReceiveNodeDao;
import com.cwd.arm.infrastructure.dao.base.DaoImpl;
import com.cwd.arm.infrastructure.mapper.ReceiveNodeMapper;
import com.cwd.arm.infrastructure.po.ReceiveNodePo;
import com.cwd.arm.infrastructure.query.ReceiveNodeDaoQuery;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

/**
* Description:收款节点
* Created on 2021年11月16日
* @author  yan
*/
@Service
public class ReceiveNodeDaoImpl extends DaoImpl<ReceiveNodeMapper, ReceiveNodePo> implements ReceiveNodeDao {

    @Override
    public List<ReceiveNodePo> selectByQuery(ReceiveNodeDaoQuery daoQuery) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq(ObjectUtils.isNotEmpty(daoQuery.getProjectId()),"project_id",daoQuery.getProjectId());
        queryWrapper.in(ObjectUtils.isNotEmpty(daoQuery.getEndDateList()),"end_date",daoQuery.getEndDateList());
        queryWrapper.apply(ObjectUtils.isNotEmpty(daoQuery.getLeEndDate()),"DATE_FORMAT(end_date,'%Y-%m-%d') <= {0}", DateUtil.dateToDateStr(daoQuery.getLeEndDate()));
        return list(queryWrapper);
    }

}
